
import os, sys
'''
文件名索引回写
'''
path = r'E:\迅雷下载\美剧\d\final fuck'
dirs = os.listdir(path)
with open(path + r'\.文件名索引.md', encoding='utf-8') as file_object:
    contents = file_object.readlines()
    for i,content in enumerate(contents):
        if i > 1:
            for j, file in enumerate(dirs):
                old_dir = os.path.join(path, file)
                content = content.replace('|', '')
                content = content.replace('\n', '')
                if content[0:3]==file[0:3]:
                    new_file = content[3:]
                    new_dir = os.path.join(path, new_file)
                    os.rename(old_dir, new_dir)
                    # print(new_dir)
                    print(new_file)